package com.hj.javaweb.service;

import com.hj.javaweb.event.CustomEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

/**
 * @Author : hujing
 * @Date: 2025/6/20 15:12
 * @Description: 事件发布
 */
@Service
public class EventPublisherService {
    
    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;
    
    public void publishEvent(String message){
        System.out.println("publish custom event,message:"+message);
        CustomEvent customEvent = new CustomEvent(this, message);
        applicationEventPublisher.publishEvent(customEvent);
    }
}
